home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / full / jbuild / setup / JBuilder / jsamples.z / Applying1.java < prev    next >
Encoding:
Java Source  |  1997-08-11  |  742 b   |  30 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2.  
  3. import COM.objectspace.jgl.*;
  4.  
  5. /**
  6.  * Applying a unary function to every element of a sequence.
  7.  *
  8.  * @see COM.objectspace.jgl.Applying
  9.  * @version 2.0.2
  10.  * @author ObjectSpace, Inc.
  11.  */
  12.  
  13. public class Applying1
  14.   {
  15.   public static void main( String[] args )
  16.     {
  17.     Array array = new Array();
  18.     array.add( "cat" );
  19.     array.add( "dog" );
  20.     array.add( "emu" );
  21.     System.out.println( "array = " + array );
  22.  
  23.     System.out.println( "Print each element to standard output" );
  24.     Applying.forEach( array.begin(), array.end(), new Print() );
  25.  
  26.     System.out.println( "Print each element to standard output" );
  27.     Applying.forEach( array, new Print() );
  28.     }
  29.   }
  30.